﻿#include <QCoreApplication>
#include <iostream>
#include <pthread.h>
#include <thread>
#include <windows.h>
#include "SingleTemplate.h"
#define NUM_THREADS 5
class a{
    SINGLETON(a)
public:
    void print()
    {
        std::cout << "单例对象地址:" << this << std::endl;
    }

};
a::a()
{

}
a::~a()
{
    std::cout << "delete a" << std::endl;
}


void threadPrint()
{
    std::thread::id threadId = std::this_thread::get_id();
    std::cout << "线程id:" << threadId << std::endl;
    a::GetInst()->print();
}
int main(int argc, char *argv[])
{
    SetConsoleOutputCP(CP_UTF8);
    QCoreApplication a(argc, argv);
    for(int i = 0; i < NUM_THREADS; i++)
    {
        std::thread a(threadPrint);
        a.join();
    }
    return 0;
}
